using System;
using System.Collections.Generic;
using Common;

namespace FSM
{
    public interface IFsm<T> where T : class
    {
        /// <summary>
        /// 获取有限状态机名称
        /// </summary>
        string Name { get; }

        /// <summary>
        /// 获取有限状态机全名称
        /// </summary>
        string FullName { get; }

        /// <summary>
        /// 获取有限状态机拥有者
        /// </summary>
        T Owner { get; }

        /// <summary>
        /// 获取有限状态机中状态的数量
        /// </summary>
        int FsmStateCount { get; }

        /// <summary>
        /// 获取有限状态机是否正在运行
        /// </summary>
        bool IsRunning { get; }

        /// <summary>
        /// 获取有限状态机是否被销毁
        /// </summary>
        bool IsDestroyed { get; }
    
        /// <summary>
        /// 获取有限状态机当前状态
        /// </summary>
        FsmState<T> CurrentState { get; }
    
        /// <summary>
        /// 获取有限状态机当前状态持续时间
        /// </summary>
        float CurrentStateDurationTime { get; }

        /// <summary>
        /// 开始有限状态机
        /// </summary>
        /// <typeparam name="TState">要开始的有限状态机状态模型</typeparam>
        void Start<TState>() where TState : FsmState<T>;

        /// <summary>
        /// 启动有限状态机
        /// </summary>
        void Start(Type stateType);

        /// <summary>
        /// 获取有限状态机是否包含指定状态
        /// </summary>
        bool HasState<TState>() where TState : FsmState<T>;

        /// <summary>
        /// 获取有限状态机是否包含指定状态
        /// </summary>
        bool HasState(Type stateType);

        /// <summary>
        /// 获取有限状态机状态
        /// </summary>
        /// <typeparam name="TState"></typeparam>
        /// <returns></returns>
        TState GetState<TState>() where TState : FsmState<T>;

        /// <summary>
        /// 获取有限状态机状态
        /// </summary>
        /// <param name="stateType"></param>
        /// <returns></returns>
        FsmState<T> GetState(Type stateType);

        /// <summary>
        /// 获取有限状态机所有状态
        /// </summary>
        /// <returns></returns>
        FsmState<T>[] GetAllStates();

        /// <summary>
        /// 获取有限状态机所有状态模型
        /// </summary>
        void GetAllStates(List<FsmState<T>> results);


        /// <summary>
        /// 是否存在有限状态机数据
        /// </summary>
        /// <param name="name">数据名称</param>
        /// <returns></returns>
        bool HasData(string name);

    
        /// <summary>
        /// 获取有限状态机数据
        /// </summary>
        /// <param name="name"></param>
        /// <typeparam name="TData"></typeparam>
        /// <returns></returns>
        TData GetData<TData>(string name) where TData : Variable;
    
        /// <summary>
        /// 获取有限状态机数据
        /// </summary>
        Variable GetData(string name);

        /// <summary>
        /// 设置有限状态机数据
        /// </summary>
        /// <param name="name"></param>
        /// <param name="data"></param>
        /// <typeparam name="TData"></typeparam>
        void SetData<TData>(string name, TData data) where TData : Variable;

        /// <summary>
        /// 设置有限状态机数据
        /// </summary>
        /// <param name="name"></param>
        /// <param name="data"></param>
        void SetData(string name, Variable data);

        /// <summary>
        /// 移除有限状态机数据
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        bool RemoveData(string name);
    }
}
